<?php
    function mydate($date)
    {
       $day=substr($date,8,2);
       //$mymonth = array('January','February','March','April','May','June','July','August','September','October','November','December');
       $mymonth = array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
       $month=substr($date,5,2);
       $year=substr($date,0,4);
       $temp=$day.' '.$mymonth[$month-1].' '.$year;
       return $temp;
    }

    if(!empty($employers))
    {
        echo "<table cellpadding=0 cellspacing=0 style='border:none' class='mytable'>";
            echo "<tr><th width='40px'>ID</th> <th width='200px'>Company Name</th><th width='135px'>Logo</th><th width='200px'>CP Name</th><th width='120px'>Phone</th><th width='120px'>Email</th><th width='120px'>Created</th><th width='175px'>Status</th><th width='175px'>Action</th></tr>";
            foreach($employers as $data)
            {
            echo "<tr>";
                echo "<td>".$data['employers']['id']."</td>";
                echo "<td><a href='javascript:view_employer(".$data['employers']['id'].")' class='sky'>".$data['employers']['company_name']."</a></td>";
                if($data['employers']['website']!='' && $data['employers']['website']!='http://')
                { echo "<td><a href='".$data['employers']['website']."'>".$html->image('../'.$data['employers']['logo'],array('class'=>'logo'))."</a></td>"; }
                else
                { echo "<td>".$html->image('../'.$data['employers']['logo'],array('class'=>'logo'))."</td>"; }
                echo "<td>".$data['employers']['salution']." ".$data['employers']['full_name']."</td>";
                echo "<td>".$data['employers']['cp_phone']."</td>";
                echo "<td><a href='mailto:".$data['employers']['cp_email']."'>".$data['employers']['cp_email']."</a></td>";
                echo "<td>".mydate($data['employers']['created'])."</td>";
                echo "<td>";
                if($data['employers']['status'] == 0)
                {
                    if($data['employers']['slip']!='')
                    {
                        echo " Waiting Approval ";
                        echo " <br> ";
                        echo $ajax->link('[ Slip ]',
                                            array('controller'=>'employers','action'=>'slip_admin',$data['employers']['id']),
                                            array('update'=>'slip','class'=>'sky','complete'=>"make_slip();")
                                         );            
                        echo "&nbsp";
                        echo $ajax->link('[ Approve ]',
                                            array('controller'=>'employers','action'=>'approve_admin',$data['employers']['id']),
                                            array('update'=>'result','class'=>'sky')
                                         );            
                    }           
                    else
                    {
                        echo " Waiting Payment ";
                    }
                }
                else
                { 
                    echo " Registered ";
                }
                
                echo "</td>";
                echo "<td>";
                echo $ajax->link('[ Edit ]',
                                    array('controller'=>'employers','action'=>'edit_admin',$data['employers']['id']),
                                    array('update'=>'slip','class'=>'sky','complete'=>"make_slip();")
                                 );            
                echo " ";
                echo $ajax->link( '[ Delete ]', 
                        array('controller' => 'employers', 'action' => 'delete_admin',$data['employers']['id']),
                        array('update' => 'result','class'=>'sky'),
                        "Are you sure ?"
                        );                           
                echo "</td>";
            echo "</tr>";
            }
            echo "<tr class='end'><td class='end' colspan=9> &nbsp </td></tr>";
        echo "</table>";            
    }
    else
    { echo "<span class='red'>Sorry, there is no data in this category</span>"; }      
    echo "<div id='slip'></div>";  
?>